<%@page import="lib_model.Product.Tax_product"%>
<%@page import="lib_model.Account.Account"%>
<%@page import="lib_model.Categories.Categories"%>
<%@page import="java.util.ArrayList"%>
<%@page import="lib_model.Orther.ReturnObj"%>
<%@page import="lib_model.Product.Products"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<jsp:include page="../templates/Admin.jsp"></jsp:include>
Login
<jsp:include page="../templates/Title.jsp"></jsp:include>
<script type="text/javascript">
	$(document).ready(function() {
		$("#createnew").click(function() {
			window.location = ("../product/ProductCreate");
		});
		$("#createfac").hide();
		$("#btcreate").click(function() {
			$("#createfac").fadeIn();
		});

		$(".btedit").click(function(){
			 window.location = "../administrator/product-new.jsp?type=update&id=" + $(this).attr("productid");
		});
	});
</script>
<jsp:include page="../templates/StyleAd.jsp"></jsp:include>
<div class="body-center w960">
<h2 class="title-show">Create New Product</h2><br><br>

<input type="button" id="createnew" value="Create Product" /> <%
 	if (request.getAttribute("Mes") != null) {
 %>
<h2><%=request.getAttribute("Mes")%></h2>
<br>
<%
	}
%>
<table class="tb">
	<thead>
		<tr>
			<th align="left" >Name</th>
			<th align="left" >Categories</th>
			<th align="left" >Account name</th>
			<th align="left" >Tax product</th>
			<th align="left" >Price</th>			
			<th align="left" >Status</th>
			<th align="left" >Date create</th>
			<th align="left" >Option</th>
		</tr>

	</thead>
	<%
		Products wh = new Products();
		ReturnObj rs = wh.Select();
		ArrayList<Products> arr = (ArrayList<Products>) rs.ObjResult;
	%>
	<tbody>
		<%
			for (Products fac : arr) {
		%>
		<tr>
			<td><b><%=fac.name%></b></td>
			<td><b><%=((Categories) ((new Categories(fac.categories_id_ref))
						.GetInformation().ObjResult)).name%></b></td>
			<td><b><%=((Account) ((new Account(fac.username_ref))
						.GetInformation().ObjResult)).username%></b></td>
			<td><b><%=((Tax_product) ((new Tax_product(
						fac.tax_product_id_ref)).GetInformation().ObjResult)).value%></b></td>
			<td><b><%=fac.price%></b></td>
			<%
				if (fac.type == 1) {
			%>
			<td><img src="../contents/icon/svn_normal.png" /></td>
			<%
				} else {
			%>
			<td><img src="../contents/icon/svn_modified.png" /></td>
			<%
				}
			%>
			<td><%=fac.date_create%></td>
			<td><b><input type="button" value="Edit" class="btedit" productid="<%=fac.id%>" /></b></td>
		</tr>
		<%
			}
		%>
	</tbody>
</table>

</div>
<jsp:include page="../templates/Footer.jsp"></jsp:include>
